package com.homework.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class test2_3 implements Callable<Integer> {

  public int i;

  public test2_3(int i) {
    this.i = i;
  }

  @Override
  public Integer call(){
    int sum = 1;
    for (int j = 1; j <= i; j++) {
      sum = sum * j;
    }
    return sum;
  }

  public static void main(String[] args) throws ExecutionException, InterruptedException {
    //
    test2_1 t1 = new test2_1(5);

    test2_2 test2 = new test2_2(5);
    Thread t2 = new Thread(test2);

    test2_3 test3 = new test2_3(5);
    FutureTask<Integer> f = new FutureTask<>(test3);
    Thread t3 = new Thread(f);

    t1.start();
    t2.start();
    t3.start();
    int resule = f.get();
    System.out.println(resule);
  }
}
